<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>药库盘点</title>
<script type="text/javascript" src="static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="static/easyui/themes/icon.css"/>
<link rel="stylesheet" href="static/easyui/themes/macosx/easyui.css"/>
</head>
<body>
<script type="text/javascript">
//时间转换 
function comformatDate(date) {
	var day = new Date(date); 
	var Year = 0; 
	var Month = 0; 
	var Day = 0; 
	var CurrentDate = ""; 
	//初始化时间 
	Year= day.getFullYear();//
	Month= day.getMonth()+1; 
	Day = day.getDate(); 
	Hour = day.getHours(); 
	 Minute = day.getMinutes(); 
	 Second = day.getSeconds(); 
	CurrentDate += Year + "-"; 
	if (Month >= 10 ) { 
		CurrentDate += Month + "-"; 
	}else { 
		CurrentDate += "0" + Month + "-"; 
	} 
	if (Day >= 10 ) { 
		CurrentDate += Day ; 
	}else { 
		CurrentDate += "0" + Day ; 
	} 
	if(Hour>=10){
		CurrentDate +=" "+Hour;
	}else{
		CurrentDate +=" "+"0"+Hour;
	}
	if(Minute>=10){
		CurrentDate +=":"+Minute;
	}else{
		CurrentDate +=":"+"0"+Minute;
	}
	if(Second>=10){
		CurrentDate +=":"+Second;
	}else{
		CurrentDate +=":"+"0"+Second;
	}
	return CurrentDate; 
};


	$(function(){		
		//盘点表格
		$('#pandianbiao').datagrid({
		    url:'pandsy',
		    pagination:true,
		    pageNumber:1,
		    pageSize:5,
		    pageList:[5,10],
		    columns:[[			    	
		    	{field:'',checkbox:true,width:"160px",align:'center'},
				{field:'inventory_yk_id',title:'盘点编号',width:"160px",align:'center'},				
				{field:'drug_pc',title:'批次',width:"160px",align:'center'},
				{field:'drug_name',title:'药品名称',width:"160px",align:'center'},
				{field:'drug_period',title:'保质期',width:"160px",align:'center'},
				{field:'cz',title:'操作',width:130,align:'center',
					formatter:function(value,row,index){
						return "<input type='button' style='background:#E4F1FB;color:#2779AA;border:none' onclick='bianji("+row.outbound_id+")' value='查看详情'/>";
					}	
				}
		    ]]			
		});
	});		
	
	//查看详情 pandxqid
	function bianji(id){
		var row=$('#pandianbiao').datagrid('getSelected');
		var id = row["inventory_yk_id"];
		//alert(id);
		
		$('#pdxqbiao').datagrid({
		    url:'pandxqid',
		    queryParams: {
		    	inventory_yk_id:id
		    },
		    columns:[[
		    	{field:'',checkbox:true,width:"130px",align:'center'},
				{field:'drug_id',title:'药品编号',width:"130px",align:'center'},
				{field:'drug_name',title:'药品名称',width:"130px",align:'center'},
				{field:'outbound_date',title:'出库时间',width:"160px",align:'center',formatter:comformatDate},
				{field:'drug_pc',title:'生产批次',width:"130px",align:'center'},
				{field:'inventory_number',title:'应有数量',width:"130px",align:'center'},
				{field:'outdetails_should_number',title:'实际数量',width:"130px",align:'center'}				
		    ]],
		    pagination:true,
		    pageNumber:1,
		    pageSize:5,
		    pageList:[5,10,15]			       
		});	
	
		$("#pandianxiangqing").window("open");//打开修改界面
	}
	
	//文本框搜索事件
	$('#exchangeSear').searchbox({
		searcher:function(value,name){
			$('#pandianbiao').datagrid({
				url:'kucunliebiao?drug_name='+value,	
			});				  
		}
	});
</script>
	<div style="border:solid 1px #19AA8D;border-radius:5px;width:950px;margin-left:90px;margin-top:30px;height:370px;">
	
		<div style="margin-top:35px;margin-left:55px;">	
			<input id="exchangeSear" class="easyui-searchbox" style="width:280px;height:30px;"
						data-options="label:'药品名称：',prompt:'请输入药品名称',labelAlign:'right'">										
		</div>
		<div style="margin-top:30px;margin-left:55px;">
			<!-- 盘点表格 -->
			<table id="pandianbiao" class="easyui-datagrid" data-options="fitColumns:true" style="width:800px;"></table>	 	
		</div>
	</div>

		<!-- 详情界面 -->
	<div id="pandianxiangqing" class="easyui-window" title="盘点详情" style="width:900px;height:350px;" data-options="iconCls:'icon-add',closed:true"> 
		 <table id="pdxqbiao" class="easyui-datagrid" data-options="fitColumns:true" style="padding:15px;height:300px;"></table>
	</div>
</body>
</html>